﻿@model Dexter.Web.Mvc.ViewModel.Backoffice.ViewsData.HomeController.HomeIndexViewData

@{
	Layout = "~/Areas/Admin/Views/Shared/_BackOffice.cshtml";
}

@section header
{
<script src="http://cdn.jquerytools.org/1.2.5/form/jquery.tools.min.js" type="text/javascript"></script>
<script type="text/javascript" src="@Url.Content( "~/Admin/Resources/CkEditor/ckeditor.js" )"></script>
<script type="text/javascript" src="@Url.Content( "~/Admin/Resources/CkEditor/adapters/jquery.js" )"></script>
<script type="text/javascript">

	$(document).ready(function () {
		var config = {
			toolbar:
					[
						['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink'],
						['Image', 'Table', 'SpecialChar', 'Code'],
						['Styles', 'Format', 'Font', 'FontSize', 'Maximize'],
					]
		};
		$('#Post_FormattedBody').ckeditor(config);
	});
</script>
}

<section class="grid_4">
	<div class="block-border">
		<div class="block-content">
			<h1>Soon published</h1>
				
			<ul class="message no-margin">
				<li>@Model.FuturePosts.Result.Count()  events found</li>
			</ul>
				
			<div class="no-margin">
				<table cellspacing="0" class="list-calendar">
					<tbody>	
						@for (int i = 0; i < 12; i++) {
							<tr  class="empty">
								<th scope="row">@DateTime.Today.AddDays( i ).Day</th>
								<td>
									<ul class="mini-menu" style="opacity: 0; ">
										<li><a href="@U.BackOffice.NewPost" title="Add post"><img src="@Url.Content( "~/admin/Resources/images/Icons/Add.png" )" width="16" height="16" /> Add post</a></li>
									</ul>
									@if (i == 0) {
										if(Model.FuturePosts.Result.Count(x => x.PublishDate.Day == DateTime.Today.Day && x.PublishDate > DateTime.Now) == 0) {
											@:"No posts"
										} else {
											<ul class="events-dots-list">
												@foreach(var post in Model.FuturePosts.Result.Where(x => x.PublishDate.Day == DateTime.Today.Day && x.PublishDate > DateTime.Now).ToList()) {
														<li><a href="@U.Post.Detail(post)" target="_blank"><span></span> "@post.Title.Cut(50)</a></li>
												}
											</ul>
										}
									} else {
										if(Model.FuturePosts.Result.Count(x => x.PublishDate.Day == DateTime.Today.AddDays(i).Day) == 0) {
											@:"No posts"
										} else {
											<ul class="events-dots-list">
												@foreach (var post in Model.FuturePosts.Result.Where(x => x.PublishDate.Day == DateTime.Today.AddDays(i).Day).ToList()) {
													<li><a href="@U.Post.Detail(post)" target="_blank"><span></span> "@post.Title.Cut(50)</a></li>
												}
											</ul>
										}
									}
								</td>
							</tr>
						}
					</tbody>
				</table>
			</div>
			
		</div>
	</div>
</section>

<section class="grid_8">
<div class="block-border">
	<form class="block-content form" id="complex_form" method="post" action="">
		<h1>Fast Post</h1>

		@Html.AntiForgeryToken()
				
		@if (!ViewData.ModelState.IsValid) {
			<ul class="message error no-margin">
				@Html.ValidationSummary()
				<li class="close-bt"></li>
			</ul>
		}
				
		<div class="columns">
			<ul class="tabs js-tabs same-height">
				<li class="current"><a href="#tab-locales" title="Locales">Writer</a></li>
				<li><a href="#tab-options" title="Options">Options</a></li>
			</ul>
							
			<div class="tabs-content">	
				<div id="tab-locales">
					<div class="infos">
						<h3>Write new post!</h3>
						<p>Use the simple form below.</p>
					</div>
									
					<div id="tab-en">
						<fieldset class="grey-bg">
							<legend>Required fields</legend>
							<div class="col-left">
								<p>
									<label for="complex-title">Page title</label>
									<span class="relative">
										@Html.TextBoxFor(x => x.Post.Title, new { @class = "full-width", placeholder = "Write here the title of the post" })
									</span>
								</p>

								<p>
									<label for="complex-title">Tags</label>
									<span class="relative">
										@Html.TextBoxFor(x => x.Post.Tags, new { @class = "full-width", placeholder = "Write here tags separeted by comma" })
									</span>
								</p>

								<p>
									<label for="complex-en-style">Category</label>
									@Html.DropDownListFor( x => x.Post.CategoryId, new SelectList ( Model.Categories, "Id", "Name" ), "-- Categories --", new { @class = "full-width" } )
								</p>

								<p>
									<label for="complex-en-style">Message</label>
									@Html.TextAreaFor(x => x.Post.FormattedBody, new { cols = "80", rows = "20"})
								</p>
							</div>
						</fieldset>
					</div>
				</div>
								
				<div id="tab-options" style="height: 423px; display: none; ">
					<fieldset class="grey-bg">
						<p>
							<label for="simple-required">Publish Date</label>
								<span class="input-type-text margin-right">
									@Html.EditorFor(x => x.Post.PublishDate)
									<img height="16" width="16" src="@Url.Content( "~/admin/Resources/images/Icons/Fugue/calendar-month.png" )" alt="calendar" />
									@Html.DropDownListFor(x => x.Post.PublishHour, new SelectList(Model.Hours, Model.Post.PublishHour))
									@Html.DropDownListFor(x => x.Post.PublishMinutes, new SelectList(Model.Minutes, Model.Post.PublishMinutes))
								</span>
								<button class="grey" type="button" id="publishToday">Today</button>
						</p>

						<p>&nbsp;</p>

						<p>
							<label for="table-display" style="display:inline">Publish</label>
							@Html.CheckBoxFor( x => x.Post.Publish, new { @class = "mini-switch"} )
								
							<label for="table-display" style="display:inline">Break Post</label>
							@Html.CheckBoxFor( x => x.Post.BreakOnAggregate, new { @class = "mini-switch"} )
							&nbsp;
							<label for="table-display" style="display:inline">Enable Comments</label>
							@Html.CheckBoxFor( x => x.Post.CommentEnabled, new { @class = "mini-switch"} )
						</p>

							
						<p>
							<label for="simple-required">Slug</label>
							@Html.TextBoxFor(x => x.Post.Slug, new { @class = "full-width", placeholder = "Write the slug of the post" })
						</p>

						<p>
							<label for="simple-required">Abstract</label>
							@Html.TextBoxFor(x => x.Post.Abstract, new { @class = "full-width", placeholder = "Write the abstract of the post" })
						</p>
					</fieldset>
				</div>

				<p class="input-with-button" style="padding-top:10px;">
					<button type="submit">Save</button>
				</p>
			</div>
		</div>
	</form>
</div>
</section>